package com.lc.railway.ui.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.widget.TextView;

import com.lc.railway.R;
import com.lc.railway.http.response.IndexnBean;
import com.xj.marqueeview.base.CommonAdapter;
import com.xj.marqueeview.base.ViewHolder;

import java.util.List;

public class SimpleTextAdapter extends CommonAdapter<IndexnBean.GggongshiBean> {

    //更新数据
    public void updateData(List<IndexnBean.GggongshiBean> data) {
        //这里的代码自己发挥，比如如下的写法等等
        mDatas.clear();
        mDatas.addAll(data);


    }
    public SimpleTextAdapter(Context context,  List<IndexnBean.GggongshiBean> datas) {
        super(context, R.layout.item_gonggao, datas);
    }

    @Override
    protected void convert(ViewHolder viewHolder, IndexnBean.GggongshiBean item, int position) {

        TextView tv = viewHolder.getView(R.id.tv_title);
        TextView tv_position = viewHolder.getView(R.id.tv_position);
        tv.setText(item.getTitle());
        tv_position.setText(String.format("%02d", (position+1)));
        tv.setEllipsize(TextUtils.TruncateAt.END);
    }
}
